package nl.borchef.map_2d_game;

import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.view.SurfaceHolder;

class splash_thread extends Thread {
	private Handler mo_handler;
    private boolean mb_surface_ready = false;
    private boolean mb_running = true;
    private long ml_start_time = 0;
    private long ml_delay = 100;
    // constructor
	public splash_thread(SurfaceHolder surfaceHolder, Context context,
			Handler handler) {
        mo_handler = handler;
	}

	public void pause(boolean paused) {
        //Log.d(this.getClass().getName(), "pause");
	}
	
	public void save_stop() {
        //Log.d(this.getClass().getName(), "save_stop");
		mb_running = false;
	}
	
	void surface_ready( boolean ready ){
		mb_surface_ready = true;
	}


	@Override
    public void run() {
        //Log.d(this.getClass().getName(), "run");
    	while( mb_running )
    	{
    		if( mb_surface_ready )
    		{
    			if( ml_start_time == 0 ){
    				ml_start_time = System.currentTimeMillis();
    			}
    			else{
    				long now = System.currentTimeMillis();
    				if( now - ml_start_time > ml_delay )
    				{
    					mo_handler.sendMessage(mo_handler.obtainMessage());
    				}
    			}
    		}
    		//Log.d(this.getClass().getName(), "run running");
            try {
            	sleep(100);
        	}
            catch (InterruptedException e) {
			}
            finally{
            }
    	}
    }
}

